<?php
# MantisBT - a php based bugtracking system

# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.

	/**
	 * @package MantisBT
	 * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
	 * @copyright Copyright (C) 2002 - 2010  MantisBT Team - mantisbt-dev@lists.sourceforge.net
	 * @link http://www.mantisbt.org
	 */
	 /**
	  * MantisBT Core API's
	  */
	require_once( 'core.php' );
	require_once( 'current_user_api.php' );
	require_once( 'compress_api.php' );
	require_once( 'filter_api.php' );
	require_once( 'last_visited_api.php' );

	auth_ensure_user_authenticated();

	$t_current_user_name = current_user_get_field( 'username' );
	$t_current_real_name = current_user_get_field( 'realname' );
	$t_current_email	 = current_user_get_field( 'email' );
	$t_current_al = current_user_get_field( 'access_level' );
	# Improve performance by caching category data in one pass
	category_get_all_rows( helper_get_current_project() );

	compress_enable();

	# don't index my view page
	html_robots_noindex();

	html_page_top1( lang_get( 'my_view_link' ) );

	if ( current_user_get_pref( 'refresh_delay' ) > 0 ) {
		html_meta_redirect( 'my_view_page.php', current_user_get_pref( 'refresh_delay' )*60 );
	}

	html_page_top2();

	print_recently_visited();

	$f_page_number		= gpc_get_int( 'page_number', 1 );

	$t_per_page = config_get( 'my_view_bug_count' );
	$t_bug_count = null;
	$t_page_count = null;

	$t_boxes = config_get( 'my_view_boxes' );
	asort ($t_boxes);
	reset ($t_boxes);
	#print_r ($t_boxes);

	$t_project_id = helper_get_current_project();
if ($t_current_al > 40) {
?>

<?php 
	echo '<br>Trung tâm Dự án và Dịch vụ<hr>	
	<div align="center">
	<table border=0 cellspacing="3" cellpadding="0" width=100%>
	<tr>
		<td valign=top>
		<table style="border:1px solid black;width:100%;height:20px;"class=ttt><tr>
			<td valign=top width=20%>
					<div style="background:#D5D5FF"><b>Danh mục</b></div><hr>
					<a href="securityservices.php" title="Home">Home</a> <br>
					<a href="securityservices.php?do=addcare">Add care</a> <br>
					<a href="securityservices.php?do=viewall">View all</a><br>
					<a href="securityservices.php?do=viewme">View me</a> <br>
					<a href="securityservices.php?do=suser">User site</a> <br>
					<a href="securityservices.php?do=summary">Summary</a> <br>
					<a href="securityservices.php?do=search">Tìm kiếm</a> <br>
			</td>';
			$do = $_GET['do'];
//Add thông tin khách hàng
		if ($do == addcare)
				{			
					echo '<td valign=top width=60%>
					<html>
					<head>
					<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
					<title>Seller management Systems</title>
					<link rel="stylesheet" href="css/style.css" type="text/css">
					<title>Nhập contact khách hàng</title> 
					<style> 
					fieldset{display: none; padding: 10px;} 
					</style> 
					</head>
					<body>	
					<form name="post" action="?do=pdata" method="post">
					<table border=1 cellpadding=0 cellspacing=0 style="border-collapse:collapse" width=100%>
						<tr><td bgcolor=#D5D5FF><b>Nhập thông tin khách hàng</b></td></tr>
						<tr><td>
						<table border=0>
							<tr><td>Tên doanh nghiệp </td>
							<td><input name="ctname" type="ctname" style="border:2px solid #DADADA;height:25px;"></td>
							<td>SDT liên lạc :</td><td><input name="ctphone" type="ctphone" style="border:2px solid #DADADA;height:25px;"></td></tr>
							<tr><td>Mã số thuế </td><td><input name="ctmst" type="ctmst" style="border:2px solid #DADADA;height:25px;"></td>
							<td>Số TK ngân hàng :</td><td><input name="ctbank" type="ctbank" style="border:2px solid #DADADA;height:25px;"></td></tr>
							<tr><td>Địa chỉ :</td><td><input name="ctaddress" type="ctaddress" style="border:2px solid #DADADA;height:25px;"><br></td>
							<td>Tỉnh/TP : </td><td><Select name="city"style="border:2px solid #DADADA;height:25px;">
									<option value =default>Chưa xác định</option>
									<option value =angiang>An Giang</option>
									<option value =brvt>Bà rịa vũng tàu</option>
									<option value =bacgiang>Bắc Giang</option>
									<option value =baclieu>bạc liêu</option>
									<option value =baccan>bắc cạn</option>
									<option value =bacninh>bắc ninh</option>
									<option value =bentre>bến tre</option>
									<option value =binhdinh>bình định</option>
									<option value =binhduong>bình dương</option>
									<option value =binhphuoc>bình phước</option>
									<option value =binhthuan>bình thuận</option>
									<option value =camau>cà mau</option>
									<option value =caobang>cao bằng</option>
									<option value =cantho>cần thơ</option>
									<option value =danang>đà nẵng</option>
									<option value =dl>đắk lắk</option>
									<option value =dn>đắk nông</option>
									<option value =dienbien>điện biên</option>
									<option value =dongnai>đồng nai</option>
									<option value =dongthap>đồng tháp</option>
									<option value =gialai>gia lai</option>
									<option value =hagiang>hà giang</option>
									<option value =hanam>hà nam</option>
									<option value =hanoi>hà nội</option>
									<option value =hatinh>hà tĩnh</option>
									<option value =haiduong>hải dương</option>
									<option value =haiphong>hải phòng</option>
									<option value =haugiang>hậu giang</option>
									<option value =hoabinh>hòa bình</option>
									<option value =hcm>hcm</option>
									<option value =hungyen>hưng yên</option>
									<option value =khanhhoa>khánh hòa</option>
									<option value =kiengiang>kiên giang</option>
									<option value =kontum>kon tum</option>
									<option value =laichau>lai châu</option>
									<option value =lamdong>lam dong</option>
									<option value =langson>lạng sơn</option>
									<option value =laocai>lào cai</option>
									<option value =longan>long an</option>
									<option value =namdinh>nam định</option>
									<option value =nghean>nghệ an</option>
									<option value =ninhbinh>ninh bình</option>
									<option value =ninhthuan>ninh thuận</option>
									<option value =phutho>phú thọ</option>
									<option value =phuyen>phú yên</option>
									<option value =quangbinh>quảng bình</option>
									<option value =quangnam>quảng nam</option>
									<option value =quangngai>quảng ngãi</option>
									<option value =quangninh>quảng ninh</option>
									<option value =quangtri>quảng trị</option>
									<option value =soctrang>sóc trăng</option>
									<option value =sonla>sơn la</option>
									<option value =tayninh>tây ninh</option>
									<option value =thaibinh>thái bình</option>
									<option value =thainguyen>thái nguyên</option>
									<option value =thanhhoa>thanh hóa</option>
									<option value =thuathienhue>thừa thiên huế</option>
									<option value =tiengiang>tiền giang</option>
									<option value =travinh>trà vinh</option>
									<option value =tuyenquang>tuyên quang</option>
									<option value =vinhlong>vĩnh long</option>
									<option value =vinhphuc>vĩnh phúc</option>
									<option value =yenbai>yên bái</option>	
								</select><br></td></tr>
							<tr>
							<td> Đối tượng: </td><td><Select name="area" style="border:2px solid #DADADA;height:25px;">
								<option value =mienbac>Dự án Miền Bắc</option>
								<option value =mientrung>Dự án Miền Trung</option>
								<option value =miennam>Dự án Miền Nam</option>
								</select><br>
							</td>
							
							<td> Phân khúc thị trường </td><td><Select name="pktt" style="border:2px solid #DADADA;height:25px;">
								<option value =bank>Ngân hàng/ Chứng khoán/ Bảo hiểm</option>
								<option value =nntw>Khối Nhà Nước TW</option>
								<option value =nnt>Khối Nhà Nước Tỉnh</option>
								<option value =anninh>Khối An Ninh - Quốc Phòng</option>
								<option value =yte>Khối Y Tế</option>
								<option value =congnghiep>Khối Công nghiệp/Nhà máy</option>
								<option value =ttdulich>Khối Thông tin/Du lịch/Báo chí</option>
								<option value =cntt>Khối công ty CNNT</option>
								<option value =telco>Khối Telco (Viễn Thông)</option>
								<option value =nangluong>Khối Năng Lượng</option>
								</select><br>
							</td>
							</tr>
							
							<tr>
							<td> Trạng thái khách hàng</td><td><Select name="custype" style="border:2px solid #DADADA;height:25px;">
								<option value=kt1>KT1</option>
								<option value=kt2>KT2</option>
								<option value=kt3>KT3</option>
								</select><br>
							</td>
							<td> Project status </td><td><Select name="pstatus" style="border:2px solid #DADADA;height:25px;">
								<option value=tiepcan>Tiếp cận</option>
								<option value=khaosat>Khảo sát</option>
								<option value=dauthau>Đầu thầu</option>
								<option value=kihopdong>Kí hợp đồng</option>
								<option value=dangtrienkhai>Đang triển khai</option>
								<option value=nghiemthu>Nghiệm thu</option>
								<option value=closedwin>ClosedWin</option>
								<option value=closedlost>ClosedLost</option>
								</select><br>
							</td>
							</tr>
							
							<tr><td>Đại diện/phụ trách:</td>
							<td><input name="nMan" type="nMan" style="border:2px solid #DADADA;height:25px;"></td>
							<td>Phone :</td><td><input name="pMan" type="pMan" style="border:2px solid #DADADA;height:25px;"></td></tr>
							<tr><td>Email :</td><td><input name="eMan" type="eMan" style="border:2px solid #DADADA;height:25px;"></td></tr>
							
							<tr><td> Providing services:</td><td>
							Pentest<input type="checkbox" name="pentest" /><br>
							Audit<input type="checkbox" name="audit" /><br>
							DDos<input type="checkbox" name="ddos" /><br>
							Train<input type="checkbox" name="train" /> <br>
							CISE<input type="checkbox" name="cise" />
							</td></tr>
							<tr><td> Doanh số dự án</td><td><input name="pdoanhso" type="text" style="border:2px solid #DADADA;height:25px;"/></td></tr>
							
						</td></tr></table>
						</table><br>
						<table border=1 cellpadding=0 cellspacing=0 style="border-collapse:collapse" width=100%>
						<tr><td bgcolor=#D5D5FF><b>Phân tích/đánh giá khách hàng
						</td></tr>
						<tr><td>
						<table>
							<tr><td> Assign to </td><td><Select name="assignto" style="border:2px solid #DADADA;height:25px;">';
								$req = mysql_query("select username from `mantis_user_table` where access_level='55'");
									while ($row = mysql_fetch_array($req)){
									if ($row['username'] != $seller)
									{
									 echo'<option value ='.$row['username'].'>'.$row['username'].'</option>';
									}}
								echo '</select><br>
								</td></tr>
							<tr><td valign=top>Thông tin chính dự án:</td><td><textarea name="infotop" cols="50%" rows="5" style="border:2px solid #DADADA;height:100px;"></textarea><br></td></tr>
							<tr><td><input name="submit" type="submit" value="submit"></td></tr>
						</table>
						</td></tr></table>
						</div>
						</form>
					</body></html></td>';
				}
						
//Ghi dữ liệu khách hàng vào data
		if ($do == pdata)
		{
				echo '<html xmlns="http://www.w3.org/1999/xhtml">
				<head>
				<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
						<title>Seller management Systems</title>
						<link rel="stylesheet" href="css/style.css" type="text/css">
						</head>
						<body>';
						
						//send information from form
						$ctname = $_POST['ctname'];
						$ctphone = $_POST['ctphone'];
						$ctmst = $_POST['ctmst'];
						$ctbank = $_POST['ctbank'];
						$ctaddress = $_POST['ctaddress'];
						$city = $_POST['city'];
						$area = $_POST['area'];
						
						$pktt = $_POST['pktt'];
						$custype = $_POST['custype'];
						$pstatus = $_POST['pstatus'];
						
						$nMan = $_POST['nMan'];
						$pMan = $_POST['pMan'];
						$eMan = $_POST['eMan'];
						
						$pentest = $_POST['pentest'];
						$audit = $_POST['audit'];
						$ddos = $_POST['ddos'];
						$train = $_POST['train'];
						$cise = $_POST['cise'];
						$pdoanhso = $_POST['pdoanhso'];
						
						$assignto = $_POST['assignto'];
						$adder = $t_current_user_name;
						$infotop = $_POST['infotop'];
						
						$time = date("H:i:s, d-m-Y");
						$start_time = time();
						
					//	if (preg_match('/^\(?[0]{1}[0-9]{2}\)?|[0-9]{3,3}?[ ][0-9]{3,3}?[0-9]{4,4}$/', $ctphone)) {
						echo '<div align=center><table border=1><tr><td align=center>';
						//Insert thong tin toan bo du an
						mysql_query("
						insert into `mantis_securityservices_table` 
						(ctname, ctphone, ctmst, ctbank, ctaddress, city, area, 
						pktt, custype, pstatus, nMan, pMan, eMan, pentest, audit, ddos, train, cise, pdoanhso,
						assignto, adder, infotop, start_time) 											
						values('$ctname','$ctphone','$ctmst','$ctbank','$ctaddress','$city','$area',
						'$pktt','$custype','$pstatus','$nMan','$pMan','$eMan','$pentest','$audit','$ddos','$train','$cise','$pdoanhso',
						'$assignto','$adder','$infotop','$start_time')");
						
						echo "Bạn đã nhập dữ liệu khách hàng <b>".$ctname."</b> thành công<br>";
						include("ssrpmail.php");
						echo  "<div align=center><br><a href='?do=viewall'>[List]</a> | <a href='logout_page.php'>[Logout]</a></div>";
						echo '</td></tr></table></div>';	
					//}
					/* else
					{ 
						echo "<div align=left>
						Bạn nhập sai số điện thoại rồi, nhập lại ngay<br>
						<b><u>Chú ý:</u></b><br>
						#Không có dấu cách ở đầu<br>#Không được thiếu đầu 0 ở đầu</div>";
					} */
						
		}
			
//Hiện thị toàn bộ danh khách hàng
		if ($do == viewall)
		{	
			$req = mysql_query("select 
			id,ctname,ctphone,ctmst,ctbank,ctaddress,city,area,pktt,custype,pstatus,nMan,pMan,eMan,pentest,audit,ddos,train,pdoanhso,ktks,
			assignto,adder,infotop, start_time
			from `mantis_securityservices_table` ORDER BY pstatus ASC");
			echo ' <td width=60% valign=top><html xmlns="http://www.w3.org/1999/xhtml">
					<head>
					<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
					<title>Seller management Systems</title>
					<link rel="stylesheet" href="css/default.css" type="text/css">
					<title></title> 
					</head>
					<body>	
					<table border=1 cellspacing=0 cellpadding=0 style="border-collapse:collapse" width=100%> 
						<tr>
							<td> <div style="background:#D5D5FF"><b>Danh sách khách hàng</b></div><hr>    
								<table border=1 bordercolor=white cellspacing=0 cellpadding=0 style="border-collapse:collapse" width=100% bgcolor=#CECEFF class=ttt>  
									<tr>
										<td width=1% HEIGHT=30><b>STT</td>
										<td width=13%><b>TÊN KHÁCH HÀNG</td>
										<td width=5%><b>TRẠNG THÁI</td>
										<td width=13%><b>PHÂN KHÚC THỊ TRƯỜNG</td>
										<td width=4%><b>sTime</td>
										<td width=3%><b>ASSIGNED TO</td>
									</tr>
								';
						$i = 0; $b = 0;
						while ($row = mysql_fetch_array($req))
						{	
						if($b%2==0)  { $sl = '#E1E1E1';}else { $sl = 'white';}
						$i++;
						$sid = $row['id'];
						$ctname = $row['ctname'];
						$ctphone = $row['ctphone'];
						$ctmst = $row['ctmst'];
						$ctbank = $row['ctbank'];
						$ctaddress = $row['ctaddress'];
						$city = $row['city'];
						$area = $row['area'];
						
						$pktt = $row['pktt'];
						$custype = $row['custype'];
						$pstatus = $row['pstatus'];
						
						$nMan = $row['nMan'];
						$pMan = $row['pMan'];
						$eMan = $row['eMan'];
						
						$pentest = $row['pentest'];
						$audit = $row['audit'];
						$ddos = $row['ddos'];
						$train = $row['train'];
						$pdoanhso = $row['pdoanhso'];
						
						$assignto = $row['assignto'];
						
						$adder = $row['adder'];
						$infotop = $row['infotop'];
						
						$time = date("H:i:s, d-m-Y");
						$start_time = (date("d-m-Y",$row['start_time']));
									
						// Print out result
						include ('changeinfo.php');
						echo '<tr>
										<td bgcolor='.$sl.'>'.$i.'</td>
										<td bgcolor='.$sl.'><a href="ssview.php?do=viewss&id='.$sid.'">'.$ctname.'</a></td>
										<td class='.$cls.'><b>'.$ptc.'</td>
										<td >'.$pk.'</td>
										<td bgcolor='.$sl.'>'.$start_time.'</td>
										<td bgcolor='.$sl.'>'.$assignto.'</td>
										</tr>';					
							}
			echo '</table></td></tr>
			</table></body></html></td>';
		}
		
//Hiện thị toàn bộ danh khách hàng
		if ($do == viewme)
		{	
			$req = mysql_query("select 
			id,ctname,ctphone,ctmst,ctbank,ctaddress,city,area,pktt,custype,pstatus,nMan,pMan,eMan,pentest,audit,ddos,train,pdoanhso,ktks,
			assignto,adder,infotop,from_unixtime(start_time)
			FROM `mantis_securityservices_table` 
			WHERE assignto ='$t_current_user_name'
			ORDER BY id DESC ");
			echo ' <td width=60% valign=top><html xmlns="http://www.w3.org/1999/xhtml">
					<head>
					<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
					<title>Seller management Systems</title>
					<link rel="stylesheet" href="css/default.css" type="text/css">
					<title></title> 
					</head>
					<body>	
					<table border=1 cellspacing=0 cellpadding=0 style="border-collapse:collapse" width=100%> 
						<tr>
							<td><div style="background:#D5D5FF"><b>Danh sách khách hàng</b></div><hr>   
								<table border=1 bordercolor=white cellspacing=0 cellpadding=0 style="border-collapse:collapse" width=100% bgcolor=#CECEFF class=ttt>  
									<tr>
										<td width=1%><b>STT</td>
										<td width=13%><b>TÊN KHÁCH HÀNG</td>
										<td width=3%><b>KHU VỰC</td>
										<td width=5%><b>STATUS</td>
										<td width=3%><b>KT</td>
										<td width=13%><b>PKTT</td>
										<td width=4%><b>sTime</td>
										<td width=3%><b>Asigned to</td>
									</tr>
								';
							$i = 0; $b = 0;
							while ($row = mysql_fetch_array($req))
							{	
									if($b%2==0)  { $sl = '#E1E1E1';}
									else { $sl = 'white';}
						$sid = $row['id'];
						$i++;
						$ctname = $row['ctname'];
						$ctphone = $row['ctphone'];
						$ctmst = $row['ctmst'];
						$ctbank = $row['ctbank'];
						$ctaddress = $row['ctaddress'];
						$city = $row['city'];
						$area = $row['area'];
						
						$pktt = $row['pktt'];
						$custype = $row['custype'];
						$pstatus = $row['pstatus'];
						
						$nMan = $row['nMan'];
						$pMan = $row['pMan'];
						$eMan = $row['eMan'];
						
						$pentest = $row['pentest'];
						$audit = $row['audit'];
						$ddos = $row['ddos'];
						$train = $row['train'];
						$pdoanhso = $row['pdoanhso'];
						
						$assignto = $row['assignto'];
						
						$adder = $row['adder'];
						$infotop = $row['infotop'];
						$time = date("H:i:s, d-m-Y");
						$start_time = $row['from_unixtime(start_time)'];
									
						// Print out result
						include ('changeinfo.php');
						echo '<tr>
										<td bgcolor='.$sl.'><a href="ssview.php?do=viewss&id='.$sid.'">'.$i.'</a></td>
										<td bgcolor='.$sl.'>'.$ctname.'</td>
										<td bgcolor='.$sl.'>'.$area.'</td>
										<td class='.$cls.'><b>'.$ptc.'</td>
										<td >'.$custype.'</td>
										<td >'.$pk.'</td>
										<td bgcolor='.$sl.'>'.$start_time.'</td>
										<td bgcolor='.$sl.'>'.$assignto.'</td>
										</tr>';					
							}
			echo '			</table>
			</td></tr></table></body></html></td>';
		}

// Summary
		if ($do == summary)
		{
			$qrdanhmuc = mysql_query("select pstatus,count(pstatus),pdoanhso from `mantis_securityservices_table` group by pstatus
			ORDER BY count(pstatus) DESC");
			
			echo '<td valignt=top width=60%>
			<table width=33% border=1 cellpadding=0 cellspacing=0 style="border-collapse:collapse;float:left;margin-right:10px">
					<tr><td bgcolor=#D5D5FF><b>Trạng thái dự án</td></tr>
					<tr><td>
					<table border=1 cellpadding=0 cellspacing=0 style="border-collapse:collapse" width=100%>
					<tr><td>Danh mục Dự án</td><td>Số lượng</td><td>Mật độ</td>';
				while ($row = mysql_fetch_array($qrdanhmuc))
				{
					$pstatus = $row['pstatus'];
					$countpstatus = $row['count(pstatus)'];
					$pdoanhso = $row['pdoanhso'];
					$dem = 2*$countpstatus ;
					echo '<tr><td><a href="">'.$pstatus.'</a></td>
					<td>'.$countpstatus.'</td>
					<td><div style="background-color:#000000; width:'.$dem.'px; height:20px"></div></td>';
				}
				echo '</table>
				</td></tr></table>';
			
			$qrpk = mysql_query("select pktt,count(pktt) from `mantis_securityservices_table` group by pktt ORDER BY count(pktt) DESC");			
			echo '<table width=37% border=1 cellpadding=0 cellspacing=0 style="border-collapse:collapse;float:left;margin-right:10px">
					<tr><td bgcolor=#D5D5FF><b>Phân khúc thị trường</td></tr>
					<tr><td>
					<table border=1 cellpadding=0 cellspacing=0 style="border-collapse:collapse" width=100%>
					<tr><td>Danh mục phân khúc</td><td>Số lượng</td><td>Mật độ</td>';
				while ($row = mysql_fetch_array($qrpk))
				{
					
					$pktt = $row['pktt'];
					include("changeinfo.php");
					$countpktt = $row['count(pktt)'];
					$dempk = 2*$countpktt;
					echo '<tr><td><a href="">'.$pk.'</a></td>
					<td>'.$countpktt.'</td>
					<td><div style="background-color:#000000; width:'.$dempk.'px; height:20px"></div></td>';
				}
				echo '</table>
				</td></tr></table>';
				
			$qrass = mysql_query("select assignto,count(assignto) from `mantis_securityservices_table` group by assignto ORDER BY count(assignto) DESC");			
			echo '<table width=27% border=1 cellpadding=0 cellspacing=0 style="border-collapse:collapse;float:left;">
					<tr><td bgcolor=#D5D5FF><b>Assign to</td></tr>
					<tr><td>
					<table border=1 cellpadding=0 cellspacing=0 style="border-collapse:collapse" width=100%>
					<tr><td>Danh mục Assignto</td><td>Số lượng</td><td>Mật độ</td>';
				while ($row = mysql_fetch_array($qrass))
				{
					
					$assignto = $row['assignto'];
					$countas = $row['count(assignto)'];
					$demas = 2*$countas;
					echo '<tr><td><a href="">'.$assignto.'</a></td>
					<td>'.$countas.'</td>
					<td><div style="background-color:#000000; width:'.$demas.'px; height:20px"></div></td>';
				}
				echo '</table>
				</td></tr></table>';
				
			$qrkt = mysql_query("select custype, count(custype) from `mantis_securityservices_table` group by custype ORDER BY count(custype) DESC");			
			echo '<table border=1 cellpadding=0 cellspacing=0 style="border-collapse:collapse;">
					<tr><td bgcolor=#D5D5FF><b>Trạng thái khách hàng</td></tr>
					<tr><td>
					<table border=1 cellpadding=0 cellspacing=0 style="border-collapse:collapse">
					<tr><td>Danh mục khách hàng</td><td>Số lượng</td><td>Mật độ</td>';
				while ($row = mysql_fetch_array($qrkt))
				{
					$custype = $row['custype'];
					$countcustype = $row['count(custype)'];
					$demkt = 2*$countcustype ;
					echo '<tr><td><a href="">'.$custype.'</a></td>
					<td>'.$countcustype.'</td>
					<td><div style="background-color:#000000; width:'.$demkt.'px; height:20px"></div></td>';
				}
				echo '</table>
				</td></tr></table></td>';
		}

// User site
		if ($do == suser)
		{
			$sqlu = mysql_query(" select username,realname from mantis_user_table where access_level=40");
			while ($row = mysql_fetch_array($sqlu))
			{
				$user = $row['username'];
				$rser = $row['realname'];
				echo ' | <a href="securityservices.php?do=suser&viewby='.$user.'">'.$rser.'</a>';
			}
				$me = $_GET['viewby'];
				$req = mysql_query("select 
					id,ctname,ctphone,ctmst,ctbank,ctaddress,city,area,pktt,custype,pstatus,nMan,pMan,eMan,pentest,audit,ddos,train,pdoanhso,ktks,
					assignto,adder,infotop,from_unixtime(start_time)
					FROM `mantis_securityservices_table` 
					WHERE assignto ='$me'
					ORDER BY id DESC ");

				echo ' <br><br><html xmlns="http://www.w3.org/1999/xhtml">
					<head>
					<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
					<title>Seller management Systems</title>
					<link rel="stylesheet" href="css/default.css" type="text/css">
					<title></title> 
					</head>
					<body>	
					<table border=1 cellspacing=0 cellpadding=0 style="border-collapse:collapse" width=100%> 
						<tr>
							<td>  <b>Danh sách khách hàng'; 
				
				echo '	</b><br><br>    
								<table border=1 bordercolor=white cellspacing=0 cellpadding=0 style="border-collapse:collapse" width=100% bgcolor=#CECEFF class=ttt>  
									<tr>
										<td width=1%><b>STT</td>
										<td width=13%><b>Tên khách hàng</td>
										<td width=2%><b>Khu vực</td>
										<td width=5%><b>Status</td>
										<td width=3%><b>KT</td>
										<td width=13%><b>PKTT</td>
										<td width=4%><b>Started on</td>
										<td width=4%><b>Last upd</td>
										<td width=3%><b>Adder</td>
										<td width=3%><b>Asigned to</td>
									</tr>
								';
							$i = 0; $b = 0;
							while ($row = mysql_fetch_array($req))
							{	
									if($b%2==0)  { $sl = '#E1E1E1';}
									else { $sl = 'white';}
						$sid = $row['id'];
						$i++;
						$ctname = $row['ctname'];
						$ctphone = $row['ctphone'];
						$ctmst = $row['ctmst'];
						$ctbank = $row['ctbank'];
						$ctaddress = $row['ctaddress'];
						$city = $row['city'];
						$area = $row['area'];
						
						$pktt = $row['pktt'];
						$custype = $row['custype'];
						$pstatus = $row['pstatus'];
						
						$nMan = $row['nMan'];
						$pMan = $row['pMan'];
						$eMan = $row['eMan'];
						
						$pentest = $row['pentest'];
						$audit = $row['audit'];
						$ddos = $row['ddos'];
						$train = $row['train'];
						$pdoanhso = $row['pdoanhso'];
						
						$assignto = $row['assignto'];
						
						$adder = $row['adder'];
						$infotop = $row['infotop'];
						
						$time = date("H:i:s, d-m-Y");
						$start_time = $row['from_unixtime(start_time)'];
									
						// Print out result
						include ('changeinfo.php');
						echo '<tr>
										<td bgcolor='.$sl.'><a href="ssview.php?do=viewss&id='.$sid.'">'.$i.'</a></td>
										<td bgcolor='.$sl.'>'.$ctname.'</td>
										<td bgcolor='.$sl.'>'.$area.'</td>
										<td class='.$cls.'><b>'.$ptc.'</td>
										<td >'.$custype.'</td>
										<td >'.$pk.'</td>
										<td bgcolor='.$sl.'>'.$start_time.'</td>
										<td bgcolor='.$sl.'>'.$last_updated.'</td>
										<td bgcolor='.$sl.'>'.$adder.'</td>
										<td bgcolor='.$sl.'>'.$assignto.'</td>
										</tr>';					
							}
			echo '			</table>
			<div>
			Hiện tại có ? khách hàng<br>
			Hiện tại có ? tiền<br>			
					</td></tr>
			</table></body></html>';
			
		}

}
else { echo "<br><div align=center><b>Bạn không có quyền truy cập vào tài nguyên khu vực này. Liên hệ lãnh đạo để hỏi!</div>";}
		?>
			</td></tr></table>
</div>

<?php
	html_page_bottom();
